package bmatch.tech.cloud.dao;

import bmatch.tech.cloud.dao.builder.FileModelSqlBuilder;
import bmatch.tech.cloud.model.FileModel;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Component;

@Component
@Mapper
public interface FileModelMapper {


    @SelectProvider(type = FileModelSqlBuilder.class,method = "query")
    List<FileModel> select(String userId, String path, String name);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table file_model
     *
     * @mbg.generated Wed Dec 05 19:08:27 CST 2018
     */
    @Delete({
        "delete from file_model",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table file_model
     *
     * @mbg.generated Wed Dec 05 19:08:27 CST 2018
     */
    @Insert({
        "insert into file_model (id, gmt_created, ",
        "user_id, path, store_path, ",
        "type, name)",
        "values (#{id,jdbcType=VARCHAR}, #{gmtCreated,jdbcType=TIMESTAMP}, ",
        "#{userId,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR}, #{storePath,jdbcType=VARCHAR}, ",
        "#{type,jdbcType=BIT}, #{name,jdbcType=VARCHAR})"
    })
    int insert(FileModel record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table file_model
     *
     * @mbg.generated Wed Dec 05 19:08:27 CST 2018
     */
    @Select({
        "select",
        "id, gmt_created, user_id, path, store_path, type, name",
        "from file_model",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="gmt_created", property="gmtCreated", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR),
        @Result(column="path", property="path", jdbcType=JdbcType.VARCHAR),
        @Result(column="store_path", property="storePath", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.BIT),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR)
    })
    FileModel selectByPrimaryKey(String id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table file_model
     *
     * @mbg.generated Wed Dec 05 19:08:27 CST 2018
     */
    @Select({
        "select",
        "id, gmt_created, user_id, path, store_path, type, name",
        "from file_model"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="gmt_created", property="gmtCreated", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR),
        @Result(column="path", property="path", jdbcType=JdbcType.VARCHAR),
        @Result(column="store_path", property="storePath", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.BIT),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR)
    })
    List<FileModel> selectAll();

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table file_model
     *
     * @mbg.generated Wed Dec 05 19:08:27 CST 2018
     */
    @Update({
        "update file_model",
        "set gmt_created = now(),",
          "user_id = #{userId,jdbcType=VARCHAR},",
          "path = #{path,jdbcType=VARCHAR},",
          "store_path = #{storePath,jdbcType=VARCHAR},",
          "type = #{type,jdbcType=BIT},",
          "name = #{name,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(FileModel record);
}